package com.example.teaching_server.service;

import com.example.teaching_server.repository.CheckInRecordRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;

/**
 * 打卡记录服务
 */
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CheckInRecordService {

    private final CheckInRecordRepository recordRepository;

    /**
     * 获取指定活动的已打卡日期列表
     */
    public List<String> getCheckedDates(Long activityId) {
        log.debug("查询活动打卡日期: activityId={}", activityId);

        return recordRepository.findDistinctDatesByActivityId(activityId)
                .stream()
                .map(LocalDate::toString)
                .toList();
    }
}
